package com.ple.app.user;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.ple.app.jzsf.R;

/**
 * Created by mcgradytien on 2016/11/21.
 */

public class FarmsInfoInputActivity extends Activity {

    private Button btnFarmInfoInputCancel;
    private Button btnFarmInfoInputConfirm;
    private TextView txtDrawFarmInfoBoundary;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.farminfo_input);

        //初始化视图
        initView();
        //初始化事件
        initEvents();
    }

    private void initView() {

        btnFarmInfoInputConfirm = (Button) findViewById(R.id.btn_farmInfoInput_confirm);
        btnFarmInfoInputCancel = (Button) findViewById(R.id.btn_farmInfoInput_cancel);
        txtDrawFarmInfoBoundary = (TextView) findViewById(R.id.txt_drawFarmBoundary);

        txtDrawFarmInfoBoundary.setText(getString(R.string.userInfo_drawBoundary_textView));
    }

    private void initEvents() {

        btnFarmInfoInputCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(FarmsInfoInputActivity.this,"取消录入！",Toast.LENGTH_LONG).show();
                Intent intent = new Intent(FarmsInfoInputActivity.this,UserInfoActivity.class);
                startActivity(intent);
            }
        });
        btnFarmInfoInputConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(FarmsInfoInputActivity.this,"录入成功！",Toast.LENGTH_LONG).show();
                Intent intent = new Intent(FarmsInfoInputActivity.this,UserInfoActivity.class);
                startActivity(intent);
                //不再进入此activity
                finish();
            }
        });
        txtDrawFarmInfoBoundary.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(FarmsInfoInputActivity.this,DrawFarmBoundaryActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(getIntent().getStringExtra("state")!=null){
            txtDrawFarmInfoBoundary.setText(getIntent().getStringExtra("state"));
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }
}
